package com.weixing.mall.provider.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.model.query.CommoditySalesQuery;
import com.weixing.mall.provider.model.query.MarketQuery;
import com.weixing.mall.provider.model.query.ReportShipperQuery;
import com.weixing.mall.provider.model.vo.CommoditySalesVo;
import com.weixing.mall.provider.model.vo.MarketReportVo;
import com.weixing.mall.provider.model.vo.ShipperReportDetailsVo;
import com.weixing.mall.provider.model.vo.ShipperReportVo;
import com.weixing.mall.provider.service.IReportShipperService;
import com.weixing.mall.provider.service.impl.CommodityDepartServiceImpl;
import com.weixing.mall.provider.service.impl.MarketServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("report")
@Api(value = "后台报表APi", tags = "后台报表")
public class ReportController extends BaseController {

    @Autowired
    private CommodityDepartServiceImpl commodityDepartService;

    @Autowired
    private MarketServiceImpl marketServiceImpl;

    @Autowired
    private IReportShipperService reportShipperService;


    @ApiOperation(value = "商品部销售报表")
    @GetMapping("/commodityDepartSale")
    public Result commodityDepartSale(CommoditySalesQuery commoditySalesQuery){
        IPage<CommoditySalesVo> result=commodityDepartService.findCommodityDepartSale(initMpPage(),commoditySalesQuery);
        return ResultUtil.success(result);
    }
    @ApiOperation(value = "销售明细报表适用于销售报表至销售明细穿透")
    @GetMapping("/commodityDepartSaleDetails")
    public Result commodityDepartSaleDetails(CommoditySalesQuery commoditySalesQuery){
        IPage<CommoditySalesVo> result=commodityDepartService.findCommodityDepartSale(initMpPage(),commoditySalesQuery);
        return ResultUtil.success(result);
    }

    @ApiOperation(value = "商品销售报表首页")
    @GetMapping("/commodityDepartSaleIndex")
    public Result commodityDepartSaleIndex(CommoditySalesQuery commoditySalesQuery){
        IPage<CommoditySalesVo> result=commodityDepartService.commodityDepartSaleIndex(initMpPage(),commoditySalesQuery);
        return ResultUtil.success(result);
    }

    @ApiOperation(value = "商品销售报表详情页")
    @GetMapping("/findByproductStatus")
    public Result findByproductStatus(CommoditySalesQuery commoditySalesQuery){
        IPage<CommoditySalesVo> result=commodityDepartService.findByproductStatus(initMpPage(),commoditySalesQuery);
        return ResultUtil.success(result);
    }

    @ApiOperation(value = "市场部销售报表")
    @GetMapping("/marketIndex")
    public Result MarketIndex(MarketQuery marketQuery){
        IPage<MarketReportVo> result=marketServiceImpl.marketIndex(initMpPage(),marketQuery);
        return ResultUtil.success(result);
    }

    @ApiOperation(value = "市场部销售报表底部整体数据")
    @GetMapping("/marketIndexBottom")
    public Result marketIndexBottom(MarketQuery marketQuery){
        MarketReportVo result=marketServiceImpl.MarketIndexBottom(marketQuery);
        return ResultUtil.success(result);
    }



    @ApiOperation(value = "发货部报表:发货员发货数据报表")
    @GetMapping("/shipperDataReport")
    public Result selectShipperDataReport(ReportShipperQuery reportShipperQuery){
        IPage<ShipperReportVo> result=reportShipperService.selectShipperDataReport(initMpPage(),reportShipperQuery);
        return ResultUtil.success(result);
    }

    @ApiOperation(value = "发货部报表:发货明细")
    @GetMapping("/shipperDataDetails")
    public Result selectShipperDataDetailsReport(ReportShipperQuery reportShipperQuery){
        IPage<ShipperReportDetailsVo> result=reportShipperService.selectShipperDataDetailsReport(initMpPage(),reportShipperQuery);
        return ResultUtil.success(result);
    }
}
